#ifndef H_EREP_UPDATER
#define H_EREP_UPDATER

#include <QtCore/QtCore>
#include <QtGui/QtGui>
#include <QtWebKit/QtWebKit>

namespace erep
{

class Communicator;

class UpdateAppendingPage : public QWizardPage
{
    Q_OBJECT
public:
    UpdateAppendingPage( QTableWidget* );
    virtual bool validatePage();
    
public slots:
    void openFile();
    bool checkInput();
    
protected:
    QTextEdit* _textBox;
};

class UpdateProgressPage : public QWizardPage
{
    Q_OBJECT
public:
    UpdateProgressPage( QTableWidget* );
    virtual void initializePage();
    virtual bool validatePage();
    virtual bool isComplete() const;
    
public slots:
    void start();
    void getPersonData( QNetworkReply* );
    void getCompanyData( QNetworkReply* );
    
signals:
    void personDataSent( const QString&, const QByteArray& );
    void companyDataSent( const QString&, const QByteArray& );
    
protected:
    bool findListItem( const QString& id, bool deleteIt=false );
    
    Communicator* _personCommunicator;
    Communicator* _companyCommunicator;
    QListWidget* _list;
    QListWidget* _logList;
    QProgressBar* _progress;
    QTableWidget* _existingDataTable;
    QString _citizenPrefix;
    QString _companyPrefix;
};

class UpdateConclusionPage : public QWizardPage
{
    Q_OBJECT
public:
    UpdateConclusionPage();
    virtual void initializePage();
    
public slots:
    void recordPersonData( const QString& );
    void recordCompanyData( const QString& );
    
protected:
    QLabel* _intro;
    QTextEdit* _citizenBox;
    QTextEdit* _companyBox;
    unsigned int _numCitizens;
    unsigned int _numCompanies;
};

class Updater : public QWizard
{
    Q_OBJECT
public:
    Updater( QWidget* parent=0, Qt::WindowFlags flags=0 );
    virtual ~Updater();
};

}

#endif
